
* Formatting
graph set window fontface "Times New Roman"	// use Times New Roman as the default font for Graph window
// 	 graph set window fontface default 			// use this to restore to factury setting if preferred later

set scheme s1mono

********************************************************************
*************** Figure A6: ***************		
use "${ddata}cleaned_data_wACSweight.dta", clear

keep treatment uuid white age male college married working_ft child_under_6 child_under_18 lincome sce current_censusdiv weight weight_ACS donation_fo donation_so donation_so_l_fo ///
	original_gap0 original_gap1 original_gap2 original_gap3 original_gap4 original_gap5
rename uuid uuid_w2
keep if uuid_w2!=""
foreach v in white age male college married working_ft child_under_6 child_under_18 lincome sce current_censusdiv donation_fo donation_so donation_so_l_fo{
	rename `v' `v'_oct2021
}
cap drop _merge
merge 1:1 uuid_w2 using "${rdata}followup_surveydata.dta" 
replace treatment = 0 if HQs1r3==1 & treatment==. 
replace treatment = 1 if HQs1r3==. & treatment==. 

rename recommend_stayhome recommend_timeoff0 
rename recommend_stayhome_w2 recommend_timeoff0_w2

rename recommend_timeoff0_w2 recommend_timeoff_w2_0
rename recommend_timeoff1_w2 recommend_timeoff_w2_1
rename recommend_timeoff2_w2 recommend_timeoff_w2_2
rename recommend_timeoff3_w2 recommend_timeoff_w2_3
rename recommend_timeoff4_w2 recommend_timeoff_w2_4
rename recommend_timeoff5_w2 recommend_timeoff_w2_5

forvalues i = 0/5{
	cap drop consistent_sample`i'
	gen consistent_sample`i' = (recommend_timeoff`i'!=. & recommend_timeoff_w2_`i'!=. & weight_ACS!=.)
} 

forvalues i=0(1)5 {
	xtile quartile_gap_`i' = original_gap`i', n(4)
	gen l_quartile_gap_`i'=quartile_gap_`i'==1 if quartile_gap_`i'~=. 
	gen iqr_gap_`i'=(quartile_gap_`i'==2|quartile_gap_`i'==3) if quartile_gap_`i'~=.
	gen h_quartile_gap_`i'=quartile_gap_`i'==4 if quartile_gap_`i'~=. 
	gen group_`i'=1 if l_quartile_gap_`i'==1
	replace group_`i'=2 if iqr_gap_`i'==1
	replace group_`i'=3 if h_quartile_gap_`i'==1
}


keep uuid_w2 uuid_w3 sce_oct2021 treatment  recommend_timeoff* recommend_timeoff_w2_*  group_* weight

reshape long recommend_timeoff recommend_timeoff_w2_ group_, i(uuid_w2) j(questions)
drop if recommend_timeoff==.

rename group_ group

gen group1=group==1 if group~=.
gen group2=group==2 if group~=.
gen group3=group==3 if group~=.

forvalues i=1(1)3 {

	gen group`i'_t = group`i'*treatment

}


label var group1_t "Bottom Quartile PG (Avg PG<0)"
label var group2_t "Middle 50% PG (Avg PG~0)"
label var group3_t "Top Quartile PG (Avg PG>0)"



*************************
*** May2023 Subfigure ***

forvalues i=0(1)5 {

	regress recommend_timeoff group1_t group2_t group3_t group1 group2 group3 if question==`i', robust

	estimates store F`i'

}

* May2023 - Panel A
count if group1==1 & question==0
local grp1_N_q1 = r(N)
dis `grp1_N_q1'

count if group2==1 & question==0
local grp2_N_q1 = r(N)
dis `grp2_N_q1'

count if group3==1 & question==0
local grp3_N_q1 = r(N)
dis `grp3_N_q1'

#delimit;
coefplot (F0, keep(group1_t group2_t group3_t)  bcolor(navy%40)), 
grid(none) vertical recast(bar)  barwidth(0.5) fcolor(*.8)  
ytitle("Treatment Effect (percentage points)", size(small))  
yline(0, lcolor(black)) coeflabels(group1_t = `""Bottom Quartile PG" "(N=`grp1_N_q1')""' group2_t = `""Middle 50% PG" "(N=`grp2_N_q1')""' group3_t = `"  "Top Quartile PG" "(N=`grp3_N_q1')""', labsize(vsmall))  
ylabel(-20(10)20,labs(small)) legend( off) title("May 2023", size(small))   
graphregion(color(white))   yscale(range(-20 20));  
graph save "${o}figA6_may23_A", replace;
#delimit cr


* May2023 - Panel B
count if group1==1 & question==1
local grp1_N_q2 = r(N)
dis `grp1_N_q2'

count if group2==1 & question==1 
local grp2_N_q2 = r(N)
dis `grp2_N_q2'

count if group3==1 & question==1 
local grp3_N_q2 = r(N)
dis `grp3_N_q2'


#delimit;
coefplot (F1, keep(group1_t group2_t group3_t) msymbol(dot) mcolor(navy) ciopts(color(navy))) 
(F2, keep(group1_t group2_t group3_t) msymbol(diamond) mcolor(maroon) ciopts(color(maroon)))  
(F3, keep(group1_t group2_t group3_t) msymbol(square) mcolor(orange) ciopts(color(orange)))  
(F4, keep(group1_t group2_t group3_t) msymbol(triangle) mcolor(emerald) ciopts(color(emerald)))  
(F5, keep(group1_t group2_t group3_t) msymbol(x) mcolor(purple) ciopts(color(purple))), 
vertical ytitle("Treatment Effect (percentage points)", size(small)) 
yline(0, lcolor(black)) coeflabels(group1_t = `""Bottom Quartile PG" "(N=`grp1_N_q2')""' group2_t = `""Middle 50% PG)" "(N=`grp2_N_q2')""' group3_t = `"  "Top Quartile PG" "(N=`grp3_N_q2')""', labsize(vsmall)) 
ylabel(-20(10)20,labs(small)) legend( rows(1) size(small) subtitle("Mother earns:", size(small)) 
label(2 "15% less") label(4 "Same") label(6 "15% more") label(8 "30% more") label(10 "50% more") ) 
title("May 2023", size(small))  legend(region(lstyle(none)))   
graphregion(color(white)) grid(none) yscale(range(-20 20)) ;
graph save "${o}figA6_may23_B", replace ;
#delimit cr





*************************	
*** Oct2021 Subfigure ***
forvalues i=0(1)5 {
	regress recommend_timeoff_w2 group1_t group2_t group3_t group1 group2 group3 if question==`i', robust
	estimates store F`i'_w2

}


* Oct2021 - Panel A
count if group1==1 & question==0
local grp1_N_q1 = r(N)
dis `grp1_N_q1'

count if group2==1 & question==0
local grp2_N_q1 = r(N)
dis `grp2_N_q1'

count if group3==1 & question==0
local grp3_N_q1 = r(N)
dis `grp3_N_q1'

#delimit;
coefplot (F0_w2, keep(group1_t group2_t group3_t)  bcolor(navy%40)), 
grid(none) vertical recast(bar)  barwidth(0.5) fcolor(*.8)  
ytitle("Treatment Effect (percentage points)", size(small))  
yline(0, lcolor(black)) coeflabels(group1_t = `""Bottom Quartile PG " "(N=`grp1_N_q1')""' 
group2_t = `""Middle 50% PG" "(N=`grp2_N_q1')""' group3_t = `"  "Top Quartile PG" "(N=`grp3_N_q1')""', 
labsize(vsmall))  ylabel(-20(10)20,labs(small)) legend( off) 
title("October 2021", size(small))   graphregion(color(white))  yscale(range(-20 20)) ;
graph save "${o}figA6_oct21_A", replace ;
#delimit cr


* Oct2021 - Panel B
count if group1==1 & question==1
local grp1_N_q2 = r(N)
dis `grp1_N_q2'

count if group2==1 & question==1 
local grp2_N_q2 = r(N)
dis `grp2_N_q2'

count if group3==1 & question==1 
local grp3_N_q2 = r(N)
dis `grp3_N_q2'


#delimit;
coefplot (F1_w2, keep(group1_t group2_t group3_t) msymbol(dot) mcolor(navy) ciopts(color(navy))) 
(F2_w2, keep(group1_t group2_t group3_t) msymbol(diamond) mcolor(maroon) ciopts(color(maroon)))  
(F3_w2, keep(group1_t group2_t group3_t) msymbol(square) mcolor(orange) ciopts(color(orange)))  
(F4_w2, keep(group1_t group2_t group3_t) msymbol(triangle) mcolor(emerald) ciopts(color(emerald)))  
(F5_w2, keep(group1_t group2_t group3_t) msymbol(x) mcolor(purple) ciopts(color(purple))), 
vertical ytitle("Treatment Effect (percentage points)", size(small)) 
yline(0, lcolor(black)) coeflabels(group1_t = `""Bottom Quartile PG" "(N=`grp1_N_q2')""' 
group2_t = `""Middle 50% PG" "(N=`grp2_N_q2')""' group3_t = `"  "Top Quartile PG" "(N=`grp3_N_q2')""', 
labsize(vsmall)) ylabel(-20(10)20,labs(small)) legend( rows(1) size(small) 
subtitle("Mother earns:", size(small)) label(2 "15% less") label(4 "Same") label(6 "15% more") 
label(8 "30% more") label(10 "50% more") ) title("Oct 2021", size(small))  
legend(region(lstyle(none)))   graphregion(color(white)) grid(none)  yscale(range(-20 20)) ;
graph save "${o}figA6_oct21_B", replace ;

#delimit cr




*************************	
*** Combine ***
gr combine  "${o}figA6_oct21_A.gph"   "${o}figA6_may23_A.gph", title("A. Scenario 1", size(small))  graphregion(color(white))
graph export "${o}follow_up_terciles_top.pdf", replace	

grc1leg "${o}figA6_oct21_B.gph"   "${o}figA6_may23_B.gph", title("B. Scenario 2", size(small)) ycommon legendfrom("${o}figA6_oct21_B.gph")  graphregion(color(white))
graph export "${o}follow_up_terciles_bottom.pdf", replace	

erase "${o}figA6_oct21_B.gph" 
erase "${o}/figA6_may23_B.gph"
erase "${o}figA6_oct21_A.gph" 
erase "${o}figA6_may23_A.gph"
